package com.dk.controller;


import com.dk.bean.Result;
import com.dk.em.ResultEnum;
import com.dk.pojo.AdvertisingPrice;
import com.dk.service.AdvertisingPriceService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 张成涛
 * @since 2021-08-12
 */
@RestController
@RequestMapping("/advertising-price")
public class AdvertisingPriceController {

    @Autowired
    private AdvertisingPriceService advertisingPriceService;

    @ApiOperation(value = "广告价格查询")
    @GetMapping
    public Result toSelect(){
       List<AdvertisingPrice> list =  advertisingPriceService.toSelect();
       return Result.buildResult(ResultEnum.SUCCESS).setData(list);
    }
    @ApiOperation(value = "广告价格增加")
    @PostMapping("toInster")
    public Result toInster(@RequestBody AdvertisingPrice advertisingPrice){
        advertisingPriceService.toInster(advertisingPrice);
        return Result.buildResult(ResultEnum.SUCCESS);
    }
    @ApiOperation(value = "广告价格修改")
    @PostMapping("toUpdate")
    public Result toUpdate(@RequestBody AdvertisingPrice advertisingPrice){
        advertisingPriceService.toUpdate(advertisingPrice);
        return Result.buildResult(ResultEnum.SUCCESS);
    }
    @ApiOperation(value = "广告价格删除")
    @DeleteMapping("{advertisingId}")
    public Result toDelet(@PathVariable("advertisingId") Integer advertisingId){
        advertisingPriceService.toDelete(advertisingId);
        return Result.buildResult(ResultEnum.SUCCESS);
    }
}

